<template>
  <div>
    <button v-if="edit" @click="showInput">点击搜索</button>
    <input ref="showbtn" v-else type="text" placeholder="输入要搜索的关键字" />
  </div>
</template>

<script>
export default {
  name: "VueDemoApp",
  data() {
    return {
      edit: "true",
    };
  },
  methods: {
    showInput() {
      this.edit = !this.edit;
      this.$nextTick(() => {
        this.$refs.showbtn.focus();
      });
    },
  },
};
</script>

<style lang="scss" scoped>
</style>